/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.anhndt.audiobook.ui.renderer;

import com.anhndt.audiobook.utils.Util;
import com.sun.lwuit.Component;
import com.sun.lwuit.Container;
import com.sun.lwuit.Label;
import com.sun.lwuit.List;
import com.sun.lwuit.layouts.BorderLayout;

/**
 *
 * @author Sun
 */
public class ItemRendererImpl extends ItemRenderer {

    Label rotateExpand;
    protected Container panel;

    public ItemRendererImpl() {
        super(ItemRenderer.TYPE_RATE);
    }

    public Component getListCellRendererComponent(List list, Object value, int index, boolean isSelected) {
        super.getListCellRendererComponent(list, value, index, isSelected);
        int size = list.size();
        if (size > 1) {
            if (rotateExpand == null) {
                rotateExpand = new Label(Util.getImage("expand").rotate(180));
                addComponent(BorderLayout.WEST, rotateExpand);
            }
            if (expand == null) {
                expand = new Label(Util.getImage("expand"));
                addComponent(BorderLayout.EAST, expand);
            }
        }
        return this;
    }

    protected void addingComponent() {
        panel = new Container(new BorderLayout());
        addingComponent(panel);
        this.addComponent(BorderLayout.CENTER, panel);
    }

    protected void addThumb() {
        panel.addComponent(BorderLayout.WEST, thumb);
    }
}
